//
//  Base.h
//  WOM
//
//  Created by leeqb on 12/3/13.
//  Copyright (c) 2013 cst. All rights reserved.
//

#ifndef WOM_Base_h
#define WOM_Base_h

#import "Constants.h"
#import "LocationHelper.h"

#import "NSString+Extend.h"
#import "UIImageView+Extend.h"
#import "AuthHelper.h"

// 第三方库
#import "MobClick.h"
#import "UMFeedback.h"
#import "UMSocial.h"

#import "FMCommonFun.h"
#import "FMPropertyHelper.h"

#import "FMRequestObject.h"
#import "FMNetwork.h"
#import "FMDownloadImage.h"

#import "PopSelectView.h"
#import "PickImageView.h"
#import "UIImage+Extend.h"
#import "FMToast.h"
#import "FMTableView.h"
#import "FMTableViewCell.h"

#import "UIImageView+AFNetworking.h"
#import "LEDownloadManager.h"

// ---------------------- 环信SDK Start ----------------------
#import "ChatDemoUIDefine.h"
#import "WCAlertView.h"
#import "TTGlobalUICommon.h"
#import "UIViewController+HUD.h"
#import "UIViewController+DismissKeyboard.h"
#import "NSString+Valid.h"

#define MR_SHORTHAND
#import "CoreData+MagicalRecord.h"

#import "EaseMob.h"
#import "EMSDKFull.h"
// ---------------------- 环信SDK End ----------------------

#ifdef DEBUG
#define GCLog(...) NSLog(__VA_ARGS__);
#define BASE_API_URL        [FMPropertyHelper valueOfPropertyKey:@"Config/Server URL Debug"]
#define EN_API_URL          1 // 调试版本接口是否密文
#else
#define GCLog(...)
#define BASE_API_URL        [FMPropertyHelper valueOfPropertyKey:@"Config/Server URL Release"]
#define EN_API_URL          1 // 正式打包版本接口密文
#endif

#define IMAGE_URL_PREFIX    [FMPropertyHelper valueOfPropertyKey:@"Config/Image URL Prefix"]
#define BASE_API_URL_WINDRUNNER        [NSString stringWithFormat:@"%@/windrunner/", BASE_API_URL]

// 接口版本号
#define INTERFACE_VERSION   1

// 沃助手版本号
#define WM_VERSION  [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

// 当前登录手机号
#define PHONE_NUM ([[NSUserDefaults standardUserDefaults] stringForKey:@"__USER_PHONE__"]==nil?@"":[[NSUserDefaults standardUserDefaults] stringForKey:@"__USER_PHONE__"])
#define CUSTOMER_NAME ([[NSUserDefaults standardUserDefaults] stringForKey:@"__USER_NAME__"]==nil?@"":[[NSUserDefaults standardUserDefaults] stringForKey:@"__USER_NAME__"])
#define CUSTOMER_LOC ([[NSUserDefaults standardUserDefaults] stringForKey:@"__USER_LOC__"]==nil?@"":[[NSUserDefaults standardUserDefaults] stringForKey:@"__USER_LOC__"])
#define LOGIN_TOKEN ([[NSUserDefaults standardUserDefaults] stringForKey:DEF_LOGIN_TOKEN]==nil?@"":[[NSUserDefaults standardUserDefaults] stringForKey:DEF_LOGIN_TOKEN])

// 当前坐标
#define CURR_COORDINATE_X [[NSUserDefaults standardUserDefaults] doubleForKey:KEY_CURR_COORDINATE_X]
#define CURR_COORDINATE_Y [[NSUserDefaults standardUserDefaults] doubleForKey:KEY_CURR_COORDINATE_Y]
#define CURR_COORDINATE_X_STR ([[NSUserDefaults standardUserDefaults] stringForKey:KEY_CURR_COORDINATE_X]?[[NSUserDefaults standardUserDefaults] stringForKey:KEY_CURR_COORDINATE_X]:@"0")
#define CURR_COORDINATE_Y_STR ([[NSUserDefaults standardUserDefaults] stringForKey:KEY_CURR_COORDINATE_Y]?[[NSUserDefaults standardUserDefaults] stringForKey:KEY_CURR_COORDINATE_Y]:@"0")

// 显示屏宽度、高度
#define SCREEN_WIDTH    [[UIScreen mainScreen] bounds].size.width
#define SCREEN_HEIGHT   [[UIScreen mainScreen] bounds].size.height

// 分辨率宽度、高度
#define RESOLUTION_WIDTH    [[UIScreen mainScreen] currentMode].size.width
#define RESOLUTION_HEIGHT   [[UIScreen mainScreen] currentMode].size.height

// 屏幕尺寸，分辨率为1136时代表4寸屏，其他代表3.5寸
#define SCREEN_INCH ((RESOLUTION_HEIGHT==1136) ? @"4" : @"3.5")

// 释放内存
#define OCD(pointer)    if((pointer) != nil) {[(pointer) release];(pointer) = nil;}

// 根据RGB值生成UIColor对象
#define RGB(r,g,b)  [UIColor colorWithRed:((float)(r))/255.0 green:((float)(g))/255.0 blue:((float)(b))/255.0 alpha:1.0]

// 主题颜色
#define THEME_COLOR RGB(96, 181, 255)
// 统一背景颜色
#define BACKGROUND_COLOR RGB(239, 239, 244)

// 由于IOS7的工具栏颜色与其他版本有区别，所以定义该宏
#define TOOLBAR_STYLE   [[[UIDevice currentDevice] systemVersion] floatValue]>=7 ? UIBarStyleDefault : UIBarStyleBlackTranslucent

// 主页数据刷新频率
#define INTERVAL_DATA_REFRESH   (30 * 60)

// 广告页刷新频率
#define INTERVAL_ADVERTISEMENT  (4 * 60 * 60)

// 由于IOS7的工具栏颜色与其他版本有区别，所以定义该宏
#define TOOLBAR_STYLE   [[[UIDevice currentDevice] systemVersion] floatValue]>=7 ? UIBarStyleDefault : UIBarStyleBlackTranslucent

// 导航栏的Y坐标，由于IOS7的Y坐标需要下移20个像素，而IOS7之前的不需要，所以才定义这个宏
#define SCREEN_TOP_SPACE ([[[UIDevice currentDevice] systemVersion] floatValue]>=7 ? 20 : 0)
#define SCREEN_TOP_SPACE_REVERSE ([[[UIDevice currentDevice] systemVersion] floatValue]>=7 ? 0 : 20) // 方便做高度适配

// 请求超时时间
#define REQUEST_TIMEOUT 10

// 判断是否是retina屏
#define IS_RETINA (RESOLUTION_HEIGHT>480 ? YES : NO)

// 横线高度，retina为0.5像素，非retina为1像素，也用于borderWidth
#define ADAPTIVE_LINE_HEIGHT (IS_RETINA ? 0.5 : 1)

// 每页显示的条数
#define LIST_PAGE_SIZE @"15"

#define degreesToRadians(x) (M_PI*(x)/180.0)

// 国际化宏
#define LocalStringBase(key) NSLocalizedStringFromTable((key), @"LocalBase", nil)
#define LocalStringMessage(key) NSLocalizedStringFromTable((key), @"LocalMessage", nil)
#define LocalStringCommon(key) NSLocalizedStringFromTable((key), @"LocalCommon", nil)
#define LocalStringFind(key) NSLocalizedStringFromTable((key), @"LocalFind", nil)
#define LocalStringEvent(key) NSLocalizedStringFromTable((key), @"LocalEvent", nil)
#define LocalStringContact(key) NSLocalizedStringFromTable((key), @"LocalContact", nil)
#define LocalStringSecurity(key) NSLocalizedStringFromTable((key), @"LocalSecurity", nil)
#define LocalStringSetting(key) NSLocalizedStringFromTable((key), @"LocalSetting", nil)
#define LocalStringFrameworkUI(key) NSLocalizedStringFromTable((key), @"LocalFrameworkUI", nil)

#endif
